home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / daemons / nfs / nfs-serv.2be / nfs-serv / nfs-server-2.2beta16 / utimes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-05  |  1.2 KB  |  58 lines

  1. /*
  2.  * utimes.c -- emulate BSD utimes with SYSV utime
  3.  * Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU Library Public License as published by
  7.  * the Free Software Foundation; either version 2, or (at your option)
  8.  * any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU Library Public License for more details.
  14.  */
  15.  
  16. #ifdef HAVE_CONFIG_H
  17. #include <config.h>
  18. #endif
  19.  
  20. #include <sys/types.h>
  21. #if defined(STDC_HEADERS) || defined(HAVE_UNISTD_H)
  22. #include <unistd.h>
  23. #endif
  24.  
  25. #ifdef HAVE_UTIME_H
  26. #include <utime.h>
  27. #endif
  28.  
  29. #ifdef HAVE_SYS_TIME_H
  30. #include <sys/time.h>
  31. #else
  32. struct timeval {
  33.     long tv_sec;
  34.     long tv_usec;
  35. };
  36. #endif
  37.  
  38. int utimes(char *path, struct timeval *tvp)
  39. {
  40.     struct utimbuf buf, *times;
  41.  
  42.     if (tvp) {
  43.         times = &buf;
  44.         times->actime = tvp[0].tv_sec;
  45.         times->modtime = tvp[1].tv_sec;
  46.     }
  47.     else {
  48. #ifdef HAVE_UTIME_NULL
  49.         times = NULL;
  50. #else
  51.         times = &buf;
  52.         times->actime = times->modtime = time(NULL);
  53. #endif
  54.     }
  55.     return utime(path, times);
  56. }
  57.  
  58.